<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/样式操作.css">
</head>
<body>
    <div class="box"></div>
    <button class="btn">点击</button>
    <script>
        var box = document.getElementsByClassName("box")[0];
        var btn = document.getElementsByTagName("button")[0];
        btn.onclick = function(){
            var i = 0;
            var cat =[];
            while(i++<3){
                cat.push(Math.floor(Math.random()*255));
            }
            box.style.backgroundColor = `rgb(${cat.join(",")})`;
        }
        
        // btn.onclick();
    </script>
</body>
</html>